package com.cloud.simplespringboot;

import com.cloud.simplespringboot.bean.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJava;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.system.JavaVersion;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class SimpleSpringbootApplication {

	public static void main(String[] args) {
		SpringApplication.run(SimpleSpringbootApplication.class, args);
	}

	@Bean
	@ConditionalOnBean(DemoBean1.class)
	public DemoBean2 demoBean2() {
		return Builder.buildDemoBean2();
	}

	@Bean
	@ConditionalOnBean(DemoBean4.class)
	public DemoBean3 demoBean3() {
		return Builder.buildDemoBean3();
	}

	@Bean
	@ConditionalOnWebApplication
	public DemoBean5 demoBean5() {
		return Builder.buildDemoBean5();
	}

	@Bean
	@ConditionalOnJava(value = JavaVersion.NINE)
	public DemoBean6 demoBean6() {
		return Builder.buildDemoBean6();
	}

}
